import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class HashSetDemo04 {
    public static void main(String[] args) {
        Set<Order> orders = new HashSet<>();
        orders.add(new Order("卫龙", 100f));//0
        orders.add(new Order("卫龙", 100f));
        System.out.println(orders.size());

        System.out.println(new Order("卫龙", 100f).hashCode());
        System.out.println(new Order("卫龙", 100f).hashCode());



    }
}


class Order {
    private String name;
    private Float price;

    public Order(String name, Float price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return Objects.equals(name, order.name) && Objects.equals(price, order.price);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, price);
    }
}
